home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / rcsify < prev    next >
Encoding:
Text File  |  1991-12-21  |  28.7 KB  |  1,129 lines

  1. Newsgroups: comp.sources.unix
  2. From: terry@cogsci.indiana.edu (Terry Jones)
  3. Subject: v25i088: rcsify - put groups of files under RCS control
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: terry@cogsci.indiana.edu (Terry Jones)
  8. Posting-Number: Volume 25, Issue 88
  9. Archive-Name: rcsify
  10.  
  11. Rcsify is a shell script intended for getting things going with RCS.  It
  12. adds Header and Log lines to all manner of files (easily extendable),
  13. creates an RCS directory and checks in the files. It checks in with the -k
  14. option if Header and Log entries exist in the file and uses rcs -c to set
  15. the comment leader correctly on the new revision groups that are created. It
  16. can be used recursively to descend a directory tree.  File types are
  17. recognised based on suffixes, though the -f option can be used to get extra
  18. help from file(1). Files of unrecognised type are ignored under the
  19. assumption that they probably aren't the sort of files you want to maintain
  20. with RCS anyway.
  21.  
  22. It does the right thing with files that start with the #! directive and also
  23. more complicated .lex, .y and .gperf files.
  24.  
  25. It's trivial to use and I (at least) use it all the time.
  26.  
  27. You need a shell with functions and an echo that allows embedded \n will
  28. definitely be an advantage.
  29.  
  30. See the man page for details.
  31.  
  32.     Terry Jones
  33.     terry@cogsci.indiana.edu
  34.  
  35. #! /bin/sh
  36. # This is a shell archive.  Remove anything before this line, then unpack
  37. # it by saving it into a file and typing "sh file".  To overwrite existing
  38. # files, type "sh file -c".  You can also feed this as standard input via
  39. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  40. # will see the following message at the end:
  41. #        "End of shell archive."
  42. # Contents:  rcsify rcsify.1 Makefile MANIFEST
  43. # Wrapped by tjones@iuvax on Fri Dec  7 08:00:19 1990
  44. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  45. if test -f 'rcsify' -a "${1}" != "-c" ; then 
  46.   echo shar: Will not clobber existing file \"'rcsify'\"
  47. else
  48. echo shar: Extracting \"'rcsify'\" \(19368 characters\)
  49. sed "s/^X//" >'rcsify' <<'END_OF_FILE'
  50. X#!/bin/sh
  51. X#
  52. X# $Header: /home/cogsci1/u2/terry/s/rcsify/RCS/rcsify,v 1.2 90/12/07 07:37:39 terry Exp Locker: terry $
  53. X#
  54. X
  55. X#
  56. X# rcsify - add RCS Header and Log headers to the start 
  57. X#          of files, then check them in (with -k if needed).
  58. X#
  59. X# usage: rcsify [-aflmNnqruv] [-help] [files...]
  60. X#
  61. X#        -a Do all files, e.g. * and .* (excluding . and ..)
  62. X#        -f use file(1) to help determine file types.
  63. X#        -l check-in uses -l
  64. X#        -m check in makefiles too.
  65. X#        -N No check in, just add Header and Log.
  66. X#        -n like make -n
  67. X#        -q be quiet. no output is given.
  68. X#        -r treat directories recursively.
  69. X#        -u check-in uses -u
  70. X#        -v verbose output.
  71. X#
  72. X#        No files => files = *
  73. X#
  74. X# NOTE:
  75. X#      Do NOT expand this file, it contains important TABS.
  76. X#      This file can be maintained by RCS. For that reason we cannot
  77. X#      mention the strings dollar_sign Header dollar_sign or
  78. X#      dollar_sign Log dollar_sign anywhere, except in the actual
  79. X#      header and actual log.
  80. X#
  81. X#
  82. X# NOTE for people planning to add new file suffix recognition.
  83. X#
  84. X# Usually this is very simple. Look at the "case $i in" case
  85. X# statement and decide where to put your new suffix. If the
  86. X# header lines will be the same as for some other suffix, just
  87. X# add the suffix to that case and you're done. For example, I
  88. X# just added the "*.perl" case to the "*.sh | *.awk" line
  89. X# since perl's commenting convention is the same as the shell's
  90. X# and so is awk's.
  91. X#
  92. X# If there is no suitable template there already, make a new case
  93. X# and follow the examples for other cases. You must make a header
  94. X# and log string and set the hdr and log variables. Also set 
  95. X# comment to be the comment leader if this file type is not known
  96. X# by RCS (the chances are it wont be).
  97. X#
  98. X# If your file type cannot take the header and log information 
  99. X# at the beginning, set fiddle to something meaningful and
  100. X# catch it later on in the "case $fiddle in" case statement.
  101. X# Take a look at what I do when finding a lex file or a shell
  102. X# script. Good luck, it's not hard.
  103. X#
  104. X# Remember to update the man page too.
  105. X#
  106. X
  107. X# Terry Jones (terry@cogsci.indiana.edu) December 7th, 1990.
  108. X#             Center for Research on Concepts & Cognition
  109. X#             510 North Fess
  110. X#             Indiana University
  111. X#             Bloomington IN 47405 USA
  112. X#
  113. X#             Largely written at PCS Computer Systeme GmbH, Munich.
  114. X#
  115. X
  116. X#
  117. X# $Log:    rcsify,v $
  118. X# Revision 1.2  90/12/07  07:37:39  terry
  119. X# Added a few new suffixes.
  120. X# 
  121. X# Revision 1.1  90/12/07  07:03:47  terry
  122. X# Initial revision
  123. X# 
  124. X
  125. X
  126. Xfullname=$0
  127. Xmyname=`basename $0`
  128. Xcwd=`pwd`
  129. Xnew_file=/tmp/_,_,rcs$$
  130. Xwarning="echo ${myname}: WARNING..."
  131. Xreport="echo ${myname}:"
  132. Xverbose=:
  133. Xcheck_in=
  134. Xrecursive=
  135. Xoptions=
  136. Xci_flags=
  137. Xall=
  138. Xuse_file=
  139. Xmake=
  140. X
  141. X#
  142. X# You need an echo that can handle embedded newlines (\n) etc.
  143. X# For system 5 people, /bin/echo does the job. On SUNs, use
  144. X# /usr/5bin/echo. Elsewhere??? 
  145. X#
  146. X# echo=/bin/echo
  147. Xecho=/usr/5bin/echo
  148. X
  149. X#
  150. X# The two variables x and X are used to control whether or not 
  151. X# lines are actually executed or not. Under normal 
  152. X# circumstances both are "". $x or $X is placed in front of
  153. X# lines that do things to files etc. So normally the $x or
  154. X# $X expands to nothing and the line is actually done.
  155. X#
  156. X# If -n is given then we wish to turn off actual processing
  157. X# but still want to see the commands that would have been done.
  158. X# in this case we assign x=echo and X=:
  159. X# Then, put $x in front of a line you want echoed and $X in
  160. X# front of a line you want not done and not echoed. It is
  161. X# important to note that you cannot put $x in front of a
  162. X# line that contains certains metacharacters (e.g. <, >, |)
  163. X# since echo's IO will be affected. In these few cases I
  164. X# test the value of $x and do the echo that way. It is also
  165. X# important to note that you can't put "" in front of a
  166. X# line that calls a builtin function (like if).
  167. X#
  168. X# "" if [ a = b ]
  169. X# if: command not found
  170. X#
  171. Xx=
  172. XX=
  173. X
  174. Xusage()
  175. X{
  176. X  $echo usage: $myname "[-aflmnNqruv] [files...]"
  177. X  exit_status=1
  178. X  exit
  179. X}
  180. X
  181. X#
  182. X# Get options.
  183. X#
  184. Xwhile [ $# -ne 0 ]
  185. Xdo
  186. X  case $1 in
  187. X    -a) all=1; options="$options $1"; shift;;
  188. X    -f) use_file=1; options="$options $1"; shift;;
  189. X    -help | -h | "-?") usage; exit 0;;
  190. X    -l) ci_flags="$ci_flags $1"; options="$options $1"; shift;;
  191. X    -m) make=1; options="$options $1"; shift;;
  192. X    -n) x=1; X=:; options="$options $1"; shift;;
  193. X    -N) check_in=0; options="$options $1"; shift;;
  194. X    -q) report=:; options="$options $1"; shift;;
  195. X    -[rR]) recursive=1; options="$options $1"; shift;;
  196. X    -u) ci_flags="$ci_flags $1"; options="$options $1"; shift;;
  197. X    -v) verbose="$echo ${myname}:"; options="$options $1"; shift;;
  198. X    *) break;;
  199. X  esac
  200. Xdone
  201. X
  202. X#
  203. X# Do this now since if the options were given as -n -q
  204. X# then up above we would have set x to be report before
  205. X# setting report to be : Get it?
  206. X# (-q -n would have been fine).
  207. X#
  208. Xcase "$x" in
  209. X  1) x="$report" ;;
  210. Xesac
  211. X
  212. X#
  213. X# Check to see if we have any files to process. If not use, "*".
  214. X# Make sure that the * is expanded now, not in the for loop
  215. X# below (or else we'll get the new RCS directory too).
  216. X# A minor point.
  217. X#
  218. X# Make sure that you say * .* in the echo that goes into sed.
  219. X# Otherwise (.* *) you will need to match against different
  220. X# things (start of line).
  221. X#
  222. Xcase $# in
  223. X  0) 
  224. X    case $all in
  225. X      1) files="`$echo * .* | sed -e 's/ \. / /' -e 's/ \.\. / /' -e 's/ \.$/ /' -e 's/ \.\.$/ /'`" ;;
  226. X      "") files="`$echo *`" ;;
  227. X    esac
  228. X  ;;
  229. X  *) files="$*";;
  230. Xesac
  231. X
  232. Xtrap 'rm -f $new_file; $verbose cleaning up.; exit 1' 1 2 3 13 15
  233. Xtrap 'rm -f $new_file; $verbose cleaning up.; exit $exit_status' 0
  234. X
  235. X#
  236. X# This assigns a value to a string as long as the string is not
  237. X# already assigned. NOTE the unneccesary (to the shell) '' in the
  238. X# middle of each assignment. This is to hide the fatal Header and
  239. X# Log strings from RCS - so we can maintain this file with RCS.
  240. X# See the NOTE at the top of this file.
  241. X#
  242. Xmake_str()
  243. X{
  244. X  case "`eval $echo '$'$1`" in
  245. X    "") ;;
  246. X     *) return;;
  247. X  esac
  248. X
  249. X  #
  250. X  # It might make sense to export these strings... 
  251. X  # Depends if we are recursive. May not be worth it anyway.
  252. X  #
  253. X  # If you don't have an echo that can take \n, this is where
  254. X  # you will feel it. One solution would be to build the strings
  255. X  # like
  256. X  #
  257. X  #   string=`echo 'line_1Zline_2Zline_3ZZ' | tr Z '\012'`
  258. X  #
  259. X  # which isn't alot of fun, but would work.
  260. X  #
  261. X
  262. X  case $1 in
  263. X    c_hdr) c_hdr='#ifndef lint\nstatic char *rcsid = "$Header''$";\n#endif\n\n';;
  264. X    c_log) c_log='\n/*\n * $Log''$\n *\n */\n';;
  265. X    doth_hdr) doth_hdr='/* $Header''$ */';;
  266. X    doth_log) doth_log='\n/*\n * $Log''$\n *\n */\n';;
  267. X    sh_hdr) sh_hdr='#\n# $Header''$\n#\n';;
  268. X    sh_log) sh_log='#\n# $Log''$\n#\n';;
  269. X    troff_hdr) troff_hdr='.\\"\n.\\" $Header''$\n.\\"';;
  270. X    troff_log) troff_log='.\\"\n.\\" $Log''$\n.\\"';;
  271. X    lisp_hdr) lisp_hdr=';;;\n;;; $Header''$\n;;;\n';;
  272. X    lisp_log) lisp_log=';;;\n;;; $Log''$\n;;;\n';;
  273. X    tex_hdr) tex_hdr='%\n% $Header''$\n%\n';;
  274. X    tex_log) tex_log='%\n% $Log''$\n%\n';;
  275. X    texinfo_hdr) texinfo_hdr='@comment\n@comment $Header''$\n@comment\n';;
  276. X    texinfo_log) texinfo_log='@comment\n@comment $Log''$\n@comment\n';;
  277. X    ti_hdr) ti_hdr='#\n# $Header''$\n#';;
  278. X    ti_log) ti_log='#\n# $Log''$\n#';;
  279. X  esac
  280. X}
  281. X
  282. X#
  283. X# Now process each file in turn. If something goes wrong, set exit_status=1
  284. X# and continue. That way when we exit (see the traps above) we will get the
  285. X# status from the last file processed.
  286. X#
  287. Xfor i in $files
  288. Xdo
  289. X  exit_status=0
  290. X  
  291. X  #
  292. X  # go back to the invocation directory, so we can process the next
  293. X  # file. We need to do this since the "file" may have a leading 
  294. X  # pathname that does not start with a '/' (i.e. that is relative to
  295. X  # cwd).
  296. X  #
  297. X  cd $cwd
  298. X
  299. X  dir=`dirname $i`
  300. X  i=`basename $i`
  301. X
  302. X  #
  303. X  # Check to see if we need to move elsewhere.
  304. X  #
  305. X  if [ ! "$dir" = "." ]
  306. X  then
  307. X    cd "$dir"
  308. X  else
  309. X    dir="$cwd"
  310. X  fi
  311. X
  312. X  if [ ! -w . ]
  313. X  then
  314. X    $warning directory $dir is not writeable
  315. X    exit_status=1
  316. X    exit
  317. X  fi
  318. X  
  319. X  $verbose "doing directory: ${dir}, file: $i"
  320. X
  321. X  #
  322. X  # Eliminate a few nasties.
  323. X  #
  324. X  case $i in
  325. X    RCS | . | ..) $verbose directory $dir/$i ignored.; continue;;
  326. X  esac
  327. X
  328. X  #
  329. X  # Recursively handle directories if -r was given, else ignore.
  330. X  #
  331. X  if [ -d $i ]
  332. X  then
  333. X    case $recursive in
  334. X      1)
  335. X        $verbose calling ourselves to handle subdirectory $dir/$i
  336. X        cd $i && $fullname $options
  337. X        #
  338. X        # get back to where we were. Need the two cd's because
  339. X        # dir may not start with a '/' and that would mean it is
  340. X        # relative to cwd.
  341. X        #
  342. X        cd $cwd
  343. X        cd $dir
  344. X        $verbose popped up a recursion level, now back at $dir
  345. X      ;;
  346. X
  347. X      "")
  348. X        $verbose ignored directory $dir/$i
  349. X      ;;
  350. X    esac
  351. X    continue
  352. X  fi
  353. X
  354. X  #
  355. X  # Make a new RCS directory if one doesn't exist.
  356. X  #
  357. X  if [ -d RCS ]
  358. X  then
  359. X    newRCS=0
  360. X  else
  361. X    newRCS=1
  362. X    $report creating new RCS directory ${dir}/RCS
  363. X    $x mkdir RCS
  364. X  fi
  365. X  #
  366. X  # If the RCS file exists in ./RCS then do nothing.
  367. X  #
  368. X  
  369. X  if [ -f RCS/${i},v ]
  370. X  then
  371. X    $report $dir/RCS/${i},v exists, if you just want to check $i in, use ci.
  372. X    exit_status=1
  373. X    continue
  374. X  fi
  375. X
  376. X  #
  377. X  # If an RCS revision group for this file exists in the current directory, 
  378. X  # move it to ./RCS and complain a bit.
  379. X  #
  380. X  if [ -f ${i},v ]
  381. X  then
  382. X    $report revision group $dir/${i},v exists, I moved it to $dir/RCS/${i},v
  383. X    $x mv ${i},v ./RCS
  384. X    $report if you just want to check $i in, use ci.
  385. X    exit_status=1
  386. X    continue
  387. X  fi
  388. X
  389. X  #
  390. X  # Figure out what sort of file we have. Then we will know what sort of
  391. X  # header to stick in it and what sort of comment leader it should
  392. X  # have.
  393. X  #
  394. X  # fiddle indicates whether we have a .y or .lex or .gperf file
  395. X  # if we do, then we have to put the header and log stuff in AFTER 
  396. X  # the initial %{ in the file.
  397. X  #
  398. X  # comment indicates the comment type. It is "" if RCS knows about
  399. X  # this type of file.
  400. X  #
  401. X  # type tells us what sort of headers to use. It will be used to build 
  402. X  # the hdr and log variables with eval.
  403. X  #
  404. X  # need tells us whether we need to add some header or log info.
  405. X  #
  406. X
  407. X  fiddle=
  408. X  hdr=
  409. X  log=
  410. X  comment=
  411. X  need=1
  412. X  minus_k=
  413. X
  414. X  case $i in
  415. X
  416. X    *,v)
  417. X      $report $dir/$i is already an RCS revision group, moved to ./RCS
  418. X      $x mv $i ./RCS
  419. X      continue
  420. X    ;;
  421. X
  422. X    *.y) 
  423. X      fiddle=lex
  424. X      $X make_str c_hdr
  425. X      $X make_str c_log
  426. X      hdr="$c_hdr"
  427. X      log="$c_log"
  428. X    ;;
  429. X
  430. X    *.lex | *.gperf)
  431. X      fiddle=lex
  432. X      $X make_str c_hdr
  433. X      $X make_str c_log
  434. X      hdr="$c_hdr"
  435. X      log="$c_log"
  436. X      comment=' * '
  437. X    ;;
  438. X
  439. X    *.[cs] | *.c++)
  440. X      $X make_str c_hdr
  441. X      $X make_str c_log
  442. X      hdr="$c_hdr"
  443. X      log="$c_log"
  444. X    ;;
  445. X
  446. X    *.h) 
  447. X      $X make_str doth_hdr
  448. X      $X make_str c_log
  449. X      hdr="$doth_hdr"
  450. X      log="$c_log"
  451. X    ;;
  452. X
  453. X    *.sh | *.awk | *.perl)
  454. X      fiddle=hash_bang
  455. X      $X make_str sh_hdr
  456. X      $X make_str sh_log
  457. X      hdr="$sh_hdr"
  458. X      log="$sh_log"
  459. X      comment='# '
  460. X    ;;
  461. X
  462. X    *.ms | *.me | *.mm | *.man | *.[1-6] )
  463. X      $X make_str troff_hdr
  464. X      $X make_str troff_log
  465. X      hdr="$troff_hdr"
  466. X      log="$troff_log"
  467. X      comment='.\\" '
  468. X    ;;
  469. X
  470. X    *.texinfo)
  471. X      $X make_str texinfo_hdr
  472. X      $X make_str texinfo_log
  473. X      hdr="$texinfo_hdr"
  474. X      log="$texinfo_log"
  475. X      comment='@comment '
  476. X    ;;
  477. X
  478. X    *.tex | *.latex)
  479. X      $X make_str tex_hdr
  480. X      $X make_str tex_log
  481. X      hdr="$tex_hdr"
  482. X      log="$tex_log"
  483. X      comment='% '
  484. X    ;;
  485. X
  486. X    *.el | *.lsp | *.lisp | *.ss | *.scm | *.cl)
  487. X      $X make_str lisp_hdr
  488. X      $X make_str lisp_log
  489. X      hdr="$lisp_hdr"
  490. X      log="$lisp_log"
  491. X      comment=';;; '
  492. X    ;;
  493. X
  494. X    *.mk | [Mm]akefile | GNUmakefile | Imakefile)
  495. X      case "$make" in
  496. X        1)
  497. X          $X make_str sh_hdr
  498. X          $X make_str sh_log
  499. X          hdr="$sh_hdr"
  500. X          log="$sh_log"
  501. X          comment='# '
  502. X        ;;
  503. X        "")
  504. X          continue
  505. X        ;;
  506. X      esac
  507. X    ;;
  508. X
  509. X    *.ti)
  510. X      $X make_str ti_hdr
  511. X      $X make_str ti_log
  512. X      hdr="$ti_hdr"
  513. X      log="$ti_log"
  514. X      comment='# '
  515. X    ;;
  516. X
  517. X    *)
  518. X      case "$use_file" in
  519. X        1)
  520. X          case "`file $i | sed -e 's/.*:[     ]*//' -e 's/symbolic link to //'`" in
  521. X            "c program"*|"assembler program"*) 
  522. X              $X make_str c_hdr
  523. X              $X make_str c_log
  524. X              hdr="$c_hdr"
  525. X              log="$c_log"
  526. X              comment=' * '
  527. X            ;;
  528. X
  529. X            "executable script"*|"commands text"*)
  530. X              fiddle=hash_bang
  531. X              $X make_str sh_hdr
  532. X              $X make_str sh_log
  533. X              hdr="$sh_hdr"
  534. X              log="$sh_log"
  535. X              comment='# '
  536. X            ;;
  537. X
  538. X            "[nt]roff, tbl,"*) 
  539. X              $X make_str troff_hdr
  540. X              $X make_str troff_log
  541. X              hdr="$troff_hdr"
  542. X              log="$troff_log"
  543. X              comment='.\\" '
  544. X            ;;
  545. X
  546. X            *) 
  547. X              $verbose "I don't know the type of $dir/$i so it will not be checked-in."
  548. X              continue
  549. X            ;;
  550. X          esac
  551. X        ;;
  552. X
  553. X        "") 
  554. X          $verbose "I don't know the type of $dir/$i so it will not be checked-in."
  555. X          continue 
  556. X        ;;
  557. X      esac
  558. X    ;;
  559. X  esac
  560. X
  561. X  #
  562. X  # Must be able to read the current file.
  563. X  #
  564. X  if [ ! -r $i ]
  565. X  then
  566. X    $warning cannot read $dir/$i
  567. X    exit_status=1
  568. X    continue
  569. X  fi
  570. X
  571. X  #
  572. X  # Check to see if the file already has RCS info fields in it.
  573. X  #
  574. X
  575. X  egrep '\$Header' $i >/dev/null 2>&1
  576. X  have_hdr=$?
  577. X
  578. X  egrep '\$Log' $i >/dev/null 2>&1
  579. X  have_log=$?
  580. X
  581. X  #
  582. X  # Make header_info contain what is needed: either both Header and Log,
  583. X  # or just Header, or just Log. Set need=0 if we don't need
  584. X  # anything in this file.
  585. X  #
  586. X
  587. X  if [ $have_hdr -ne 0 -a $have_log -ne 0 ]
  588. X  then
  589. X    header_info="$hdr$log"
  590. X    add_str="Header and Log"
  591. X    $verbose RCS $add_str information will be added to $dir/$i
  592. X  elif [ $have_hdr -ne 0 ]
  593. X  then
  594. X    header_info="$hdr"
  595. X    add_str="Header"
  596. X    $verbose RCS $add_str information will be added to $dir/$i
  597. X  elif [ $have_log -ne 0 ]
  598. X  then
  599. X    header_info="$log"
  600. X    add_str="Log"
  601. X    $verbose RCS $add_str information will be added to $dir/$i
  602. X  else
  603. X    header_info=
  604. X    need=0
  605. X  fi
  606. X
  607. X  #
  608. X  # If some info is needed, add it.
  609. X  #
  610. X  if [ $need -eq 1 ]
  611. X  then
  612. X    #
  613. X    # Are we doing this for real? If not then skip this section.
  614. X    # It's too hard to give verbose info on what we're doing
  615. X    # if we're not really doing it.
  616. X    #
  617. X    if [ -z "$x" ]
  618. X    then
  619. X      case $fiddle in
  620. X        lex)
  621. X          #
  622. X          # Fiddle with the .y or .lex or .gperf file
  623. X          # We break it into two pieces using sed. We do a check to see
  624. X          # that the character counts are ok too.
  625. X          # Then cat the pieces back into the new file, with the header 
  626. X          # stuff in the middle.
  627. X          #
  628. X  
  629. X          line="`egrep -n '^[     ]*%{[     ]*$' $i | cut -d: -f1`"
  630. X          if [ $? -eq 0 -a -n "$line" ]
  631. X          then
  632. X            sed -e 1,$line\!d $i > $new_file
  633. X            line=`expr $line + 1`
  634. X            $echo "$header_info" >> $new_file
  635. X            sed -e $line,\$\!d $i >> $new_file
  636. X  
  637. X            #
  638. X            # Simple check that all is well.
  639. X            #
  640. X            result_sz=`wc -c < $new_file`
  641. X            head_len=`$echo "$header_info" | wc -c`
  642. X            orig_sz=`wc -c < $i`
  643. X  
  644. X            if [ "$result_sz" -ne "`expr $orig_sz + $head_len`" ]
  645. X            then
  646. X              $report "bad checksum after split of file $dir/${i}. (file ignored)"
  647. X              continue
  648. X            fi
  649. X          else
  650. X            $report "could not locate '%{' line in $dir/${i}. (file ignored)"
  651. X            exit_status=1
  652. X            continue
  653. X          fi
  654. X        ;;
  655. X
  656. X        hash_bang)
  657. X          #
  658. X          # Watch for files that start with #!...
  659. X          # For these, we make a new file consisting of the first line of the
  660. X          # old, the header info and then the rest of the old file.
  661. X          #
  662. X          first_line="`head -1 $i`"
  663. X          case "$first_line" in
  664. X            \#!*)
  665. X              #
  666. X              # Special #! directive. Make it the first line of the new file.
  667. X              #
  668. X              $echo "$first_line" > $new_file
  669. X              $echo "$header_info" >> $new_file
  670. X              tail +2 $i >> $new_file
  671. X            ;;
  672. X
  673. X            *)
  674. X              #
  675. X              # A normal file.
  676. X              #
  677. X              $echo "$header_info" > $new_file
  678. X              cat $i >> $new_file
  679. X            ;;
  680. X          esac
  681. X
  682. X          #
  683. X          # Check that everything went ok.
  684. X          #
  685. X          if [ $? -ne 0 ]
  686. X          then
  687. X            $warning "could not create new file for $dir/${i}, Aborting!"
  688. X            exit_status=1
  689. X            exit
  690. X          fi
  691. X        ;;
  692. X        
  693. X        *)
  694. X          #
  695. X          # A normal file, just cat the header and the file into a new file.
  696. X          #
  697. X
  698. X          $echo "$header_info" > $new_file
  699. X          cat $i >> $new_file
  700. X
  701. X          #
  702. X          # Check to see that the cat went ok.
  703. X          # If not we don't want to proceed or we might clobber the original without
  704. X          # having anything to replace it with.
  705. X          #
  706. X          if [ $? -ne 0 ]
  707. X          then
  708. X            $warning "could not create new file for $dir/${i}, Aborting!"
  709. X            exit_status=1
  710. X            exit
  711. X          fi
  712. X        ;;
  713. X      esac
  714. X
  715. X      #
  716. X      # Copy new_file (don't mv). It will be clobbered next time around or
  717. X      # removed if this is the last time.
  718. X      #
  719. X      $X cp $new_file $i
  720. X
  721. X      #
  722. X      # Check to see how the cp went.
  723. X      # If it failed then $i is still intact (hopefully).
  724. X      #
  725. X      if [ $? -ne 0 ]
  726. X      then
  727. X        $warning "could not copy $new_file to $dir/${i}, Aborting!"
  728. X        exit_status=1
  729. X        exit
  730. X      fi
  731. X
  732. X      $report RCS $add_str information added to $dir/$i
  733. X    fi
  734. X  else
  735. X    #
  736. X    # The header information was already there.
  737. X    #
  738. X
  739. X    $verbose RCS Header and Log information is present in $dir/$i
  740. X
  741. X    case "$check_in" in
  742. X      0)
  743. X        #
  744. X        # They just wanted to add the info, but it was there already.
  745. X        #
  746. X        $report $dir/$i already contains Header/Log information.
  747. X        exit_status=1
  748. X        continue
  749. X      ;;
  750. X    esac
  751. X
  752. X    #
  753. X    # Ci with -k if this has never been checked in before.
  754. X    # This will let RCS use the already present version number correctly.
  755. X    #
  756. X    if [ ! -f RCS/${i},v ]
  757. X    then
  758. X      $verbose $dir/RCS/${i},v does not exist, check in will use -k.
  759. X      minus_k=-k
  760. X    fi
  761. X  fi
  762. X
  763. X  #
  764. X  # If they don't want to check in then go on to the next file.
  765. X  #
  766. X  case "$check_in" in
  767. X    0) continue ;;
  768. X  esac
  769. X
  770. X  #
  771. X  # Check it in...
  772. X  #
  773. X  # If there is an unrecognised (by RCS) comment style, do the 
  774. X  # rcs -i first so that we can call rcs -c on the RCS file
  775. X  # before we do the ci -u. This is because ci -u will do a co and
  776. X  # we want to have the comment string already set up when that 
  777. X  # happens - otherwise the immediately checked out version will
  778. X  # differ from the one we just checked in.
  779. X  #
  780. X
  781. X  $report checking in $dir/$i
  782. X
  783. X  case "$comment" in
  784. X
  785. X    "") 
  786. X      case "$x" in
  787. X        "") $echo Auto-checkin done by $myname | ci -q $ci_flags $minus_k $i ;;
  788. X        *) $report "$echo Auto-checkin done by $myname | ci -q $ci_flags $minus_k $i" ;;
  789. X      esac
  790. X    ;;
  791. X    *) 
  792. X      case "$x" in
  793. X        "") $echo Auto-checkin done by $myname | rcs -q -i -c"$comment" $i ;;
  794. X        *) $report "$echo Auto-checkin done by $myname | rcs -q -i -c'$comment' $i" ;;
  795. X      esac
  796. X      $x ci -q $ci_flags $minus_k $i
  797. X    ;;
  798. X  esac
  799. Xdone
  800. END_OF_FILE
  801. if test 19368 -ne `wc -c <'rcsify'`; then
  802.     echo shar: \"'rcsify'\" unpacked with wrong size!
  803. fi
  804. # end of 'rcsify'
  805. fi
  806. if test -f 'rcsify.1' -a "${1}" != "-c" ; then 
  807.   echo shar: Will not clobber existing file \"'rcsify.1'\"
  808. else
  809. echo shar: Extracting \"'rcsify.1'\" \(5455 characters\)
  810. sed "s/^X//" >'rcsify.1' <<'END_OF_FILE'
  811. X.\"
  812. X.\" $Header: /home/cogsci1/u2/terry/s/rcsify/RCS/rcsify.1,v 1.1 90/12/07 07:37:54 terry Exp Locker: terry $
  813. X.\"
  814. X.\"
  815. X.\" $Log:    rcsify.1,v $
  816. X.\\" Revision 1.1  90/12/07  07:37:54  terry
  817. X.\\" Initial revision
  818. X.\\" 
  819. X.\\" 
  820. X.\"
  821. X.TH RCSIFY 1 "" 
  822. X.SH NAME
  823. Xrcsify \- Convert files/directories to use RCS.
  824. X.SH SYNOPSIS
  825. X.B rcsify
  826. X[ \-aflmNnqruv ]
  827. X[ files... ]
  828. X.SH DESCRIPTION
  829. X.B Rcsify
  830. Xinserts RCS Log and Header fields into files, creates an RCS directory
  831. X(if one is not already present) and checks in the files. By default it
  832. Xwill check in only files with a recognised suffix (see below). Files 
  833. Xthat already contain RCS Header or Log information are checked in with
  834. X\fBci \-k\fR. 
  835. X.B Rcsify
  836. Xalso determines the comment type appropriate to the files and uses
  837. X.B rcs \-c
  838. Xto set the correct string.
  839. X
  840. X.I file
  841. Xwill usually be a file in the current directory, but it is also
  842. Xpossible to give a filename containing path information. In this case
  843. X.B rcsify
  844. Xwill create the RCS revision group in the appropriate directory.
  845. XUse the \-v and \-n options (see below) if you are unsure about the action(s)
  846. Xthat 
  847. X.B rcsify
  848. Xwill take.
  849. X.SH FILE TYPES
  850. X.B Rcsify
  851. Xcurrently recognises the following file suffixes:
  852. X.TP
  853. X.B ,v
  854. XRCS revision group files. These are moved to the RCS directory if they are
  855. Xnot already there.
  856. X.TP
  857. X.B .awk
  858. XAwk scripts.
  859. X.TP
  860. X.B .c
  861. XC files.
  862. X.TP
  863. X.B .c++
  864. XC++ files.
  865. X.TP
  866. X.B .cl
  867. XCommon lisp files.
  868. X.TP
  869. X.B .el
  870. XEmacs lisp files.
  871. X.TP
  872. X.B .gperf
  873. XGNU gperf files.
  874. X.TP
  875. X.B .h
  876. XC language header files.
  877. X.TP
  878. X.B .latex
  879. XLatex files.
  880. X.TP
  881. X.B .lex
  882. XLex files.
  883. X.TP
  884. X.B .lisp
  885. XLisp files.
  886. X.TP
  887. X.B .lsp
  888. XLisp files.
  889. X.TP
  890. X.B .man
  891. XTroff man pages.
  892. X.TP
  893. X.B .[1-6]
  894. XTroff man pages.
  895. X.TP
  896. X.B .me
  897. XTroff me macro files.
  898. X.TP
  899. X.B .mm
  900. XTroff mm macro files.
  901. X.TP
  902. X.B .ms
  903. XTroff ms macro files.
  904. X.TP
  905. X.B .perl
  906. XPerl scripts.
  907. X.TP
  908. X.B .s
  909. XAssembler files.
  910. X.TP
  911. X.B .scm
  912. XScheme files.
  913. X.TP
  914. X.B .sh
  915. XShell scripts.
  916. X.TP
  917. X.B .ss
  918. XScheme files.
  919. X.TP
  920. X.B .tex
  921. XTex files.
  922. X.TP
  923. X.B .texinfo
  924. XGNU texinfo files.
  925. X.TP
  926. X.B .ti
  927. XTerminfo files.
  928. X.TP
  929. X.B .y
  930. XYacc files.
  931. X.SH OPTIONS
  932. X.B Rcsify 
  933. Xtakes a variety of options which can be used to control various 
  934. Xaspects of its behaviour, such as check in style, file type recognition,
  935. Xdiagnostic output and more. The meaning of each of the options is 
  936. Xexplained below.
  937. X.TP
  938. X.B \-a
  939. XAll files. Normally
  940. X.B rcsify 
  941. Xdoes not consider files that start with a leading dot. This option
  942. X(similar to the
  943. X.B \-a
  944. Xoption on 
  945. X.BR ls )
  946. Xtells
  947. X.B rcsify
  948. Xto consider all files. However, "." and ".." are always ignored unless
  949. Xpresent on the command line that
  950. X.B rcsify
  951. Xwas invoked with.
  952. X.TP
  953. X.B \-f
  954. XUse 
  955. X.BR file(1) .
  956. XNormally 
  957. X.B rcsify
  958. Xrecognises files based solely on their suffixes, as given in the
  959. Xabove list. The
  960. X.B \-f
  961. Xoption tells
  962. X.B rcsify
  963. Xto use
  964. X.B file(1)
  965. Xto try to determine the file type in the event that the above suffix
  966. Xrecognition fails. If
  967. X.B file(1)
  968. Xrecognises the file as being of one of the above types then it is
  969. Xchecked in in exactly the same fashion as it would have been had
  970. Xit had the suffix. This is useful to force 
  971. X.B rcsify
  972. Xto recognise (for example) troff source manual pages, or shell
  973. Xscripts whose names do not end with 
  974. X.BR .sh .
  975. X.TP
  976. X.B \-l
  977. XCheck in with 
  978. X.BR \-l .
  979. XNormally 
  980. X.B rcsify
  981. Xchecks the files in with
  982. X.B ci -q
  983. X(quiet). This option adds 
  984. X.B \-l
  985. Xto the check in flags. This results in an immediate
  986. X.B co \-l
  987. Xbeing done by 
  988. X.BR ci .
  989. XSee the 
  990. X.B \-l 
  991. Xoption for
  992. X.BR ci(1) .
  993. X.TP
  994. X.B \-m
  995. XThis causes 
  996. X.B rcsify
  997. Xto recognise makefiles. If a file named
  998. X"makefile", "Makefile", "GNUmakefile", "Imakefile" or "*.mk"
  999. Xis encountered, then it is treated as a makefile,
  1000. Xthe appropriate header and log information is 
  1001. Xadded and the file is checked in.
  1002. X.TP
  1003. X.B \-N
  1004. XNo check in. 
  1005. X.B Rcsify
  1006. Xwill add the header and log fields to the files and create an
  1007. XRCS directory if necessary, but will not check in any files.
  1008. X.TP
  1009. X.B \-n
  1010. XThis is essentially the same as the 
  1011. X.B \-n
  1012. Xoption for 
  1013. X.BR make(1) .
  1014. XNo actions are actually performed but the usual
  1015. Xdiagnostic messages appear as though
  1016. X.B rcsify
  1017. Xwere actually doing the work. This is very useful to
  1018. Xcheck that what
  1019. X.B rcsify
  1020. Xwould do is sensible, before actually doing it.
  1021. X.TP
  1022. X.B \-q
  1023. XQuiet mode. 
  1024. X.B Rcsify
  1025. Xwill not print diagnostic messages to show what it is doing.
  1026. XError messages will still appear.
  1027. X.TP
  1028. X.B \-r
  1029. XRecursive. Normally, when 
  1030. X.B rcsify
  1031. Xencounters a directory it is ignored. With the 
  1032. X.B \-r
  1033. Xoption,
  1034. X.B rcsify
  1035. Xcalls itself on the subdirectory.
  1036. X.TP
  1037. X.B \-u
  1038. XCheck in with 
  1039. X.BR \-u .
  1040. XNormally 
  1041. X.B rcsify
  1042. Xchecks the files in with
  1043. X.B ci -q
  1044. X(quiet). This option adds 
  1045. X.B \-u
  1046. Xto the check in flags. This results in an immediate
  1047. X.B co
  1048. Xbeing done by 
  1049. X.BR ci .
  1050. XSee the 
  1051. X.B \-u
  1052. Xoption for
  1053. X.BR ci(1) .
  1054. X.TP
  1055. X.B \-v
  1056. XVerbose output. With this option 
  1057. X.B rcsify
  1058. Xgives alot of information about what it is doing. This is 
  1059. Xvery useful with the 
  1060. X.B \-n
  1061. Xoption.
  1062. X.SH NOTES
  1063. X.B Rcsify
  1064. Xattempts to do the right thing to shell scripts, awk scripts and perl scripts
  1065. Xwhich begin with the #! directive. It also deals with .lex, .y and .gperf files
  1066. Xin a sensible fashion. Check the results if you have any worries.
  1067. X.SH AUTHOR
  1068. XTerry Jones
  1069. X.br
  1070. XCenter for Research on Concepts & Cognition
  1071. X.br
  1072. X510 North Fess
  1073. X.br
  1074. XIndiana University
  1075. X.br
  1076. XBloomington IN 47405 USA
  1077. X.br
  1078. X.SH SEE ALSO
  1079. Xci(1L), ident(1L), rcs(1L), rcsdiff(1L), rcsintro(1L), rcsmerge(1L), rlog(1L),
  1080. Xrcsfile(5L)
  1081. X.sp 0
  1082. XWalter F. Tichy, "Design, Implementation, and Evaluation of a Revision Control
  1083. XSystem," in \fIProceedings of the 6th International Conference on Software
  1084. XEngineering\fR, IEEE, Tokyo, Sept. 1982.
  1085. END_OF_FILE
  1086. if test 5455 -ne `wc -c <'rcsify.1'`; then
  1087.     echo shar: \"'rcsify.1'\" unpacked with wrong size!
  1088. fi
  1089. chmod +x 'rcsify.1'
  1090. # end of 'rcsify.1'
  1091. fi
  1092. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  1093.   echo shar: Will not clobber existing file \"'Makefile'\"
  1094. else
  1095. echo shar: Extracting \"'Makefile'\" \(57 characters\)
  1096. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  1097. X
  1098. Xrcsify.cat : rcsify.1
  1099. X    nroff -man rcsify.1 > rcsify.cat
  1100. END_OF_FILE
  1101. if test 57 -ne `wc -c <'Makefile'`; then
  1102.     echo shar: \"'Makefile'\" unpacked with wrong size!
  1103. fi
  1104. # end of 'Makefile'
  1105. fi
  1106. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  1107.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  1108. else
  1109. echo shar: Extracting \"'MANIFEST'\" \(159 characters\)
  1110. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  1111. X
  1112. XThis shar comes with the following files...
  1113. X
  1114. XMakefile..................57
  1115. Xrcsify....................19368
  1116. Xrcsify.1..................5455
  1117. X
  1118. XAnd this MANIFEST.
  1119. X
  1120. END_OF_FILE
  1121. if test 159 -ne `wc -c <'MANIFEST'`; then
  1122.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  1123. fi
  1124. # end of 'MANIFEST'
  1125. fi
  1126. echo shar: End of shell archive.
  1127. exit 0
  1128.  
  1129.